package com.agents.builder.common.ai.strategy.impl;

import com.agents.builder.common.ai.enums.LlmProvider;
import com.agents.builder.common.ai.strategy.common.BaseChatModelBuilder;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.ai.openai.OpenAiChatOptions;
import org.springframework.ai.openai.api.OpenAiApi;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class QwenChatModelBuilder extends BaseChatModelBuilder {

    private static final String DEFAULT_BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode";



    @Override
    public LlmProvider provider() {
        return LlmProvider.QWEN;
    }



    @Override
    public ChatModel getChatModel(String apiKey, String baseUrl,String modelName) {
        return new OpenAiChatModel(new OpenAiApi(Optional.ofNullable(baseUrl).orElse(DEFAULT_BASE_URL), apiKey), OpenAiChatOptions.builder().model(modelName).build());
    }
}
